<?php
namespace api\action\article;

use Yii;
use yii\data\ActiveDataProvider;
use yii\rest\IndexAction as BaseIndexAction;
use common\models\Article;

class IndexAction extends BaseIndexAction
{
    public function init()
    {
        parent::init();
        Yii::$container->set('yii\data\Pagination', [
            'pageSize' => 100,
        ]);

        // 过滤的条件
        $this->dataFilter = [
            'class' => 'yii\data\ActiveDataFilter',
            'searchModel' => function () {
                return (new \yii\base\DynamicModel(['cid' => null, 'status' => null]))
                    ->addRule('status', 'integer')
                    ->addRule('cid', 'integer');
            },
            'filter' => Yii::$app->request->get()
        ];
    }

}
